package com.linewell.license.demo.security;

import com.linewell.license.demo.utils.CurrentRequestUtils;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;
import org.springframework.stereotype.Component;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
* @author
* Company:
* Createtime : 2019年1月2日 下午3:31:48
* Description : 退出操作成功
*/
@Component
public class SecurityLogoutSuccessHandler implements LogoutSuccessHandler {

	@Override
	public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
		//使session失效
		CurrentRequestUtils.getSession().invalidate();
		CurrentRequestUtils.sendRedirect(request , response ,"/loginOut.html");
	}

}
